/*
 * @Author: szx
 * @Date: 2022-05-06 15:02:48
 * @LastEditTime: 2022-05-06 15:15:54
 * @Description:
 * @FilePath: \leetcode\900-999\933\933.js
 */
var RecentCounter = function () {
    this.que = [];
};

/**
 * @param {number} t
 * @return {number}
 */
RecentCounter.prototype.ping = function (t) {
    while (this.que && this.que[0] < t - 3000) {
        this.que.shift();
    }
    this.que.push(t);
    return this.que.length;
};

var RecentCounter = function () {
    this.que = [];
    this.start = 0;
};

/**
 * @param {number} t
 * @return {number}
 */
RecentCounter.prototype.ping = function (t) {
    while (this.start < this.que.length && this.que[start] < t - 3000) {
        start++;
    }
    this.que.push(t);
    return this.que.length - this.start;
};
